package com.wan.controller;

import com.wan.annotation.RequiresPermissions;
import com.wan.client.UserClient;
import com.wan.entity.User;
import com.wan.service.IBrandService;
import com.wan.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sf
 * @since 2025-01-13
 */
@RestController
@RequestMapping("/brand")
public class BrandController {
    private final UserClient userClient;
    @Autowired
    private IBrandService brandService;
    @Autowired
    private UserClient client;
    @Autowired
    private LoadBalancerClient loadBalancerClient;
    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    public BrandController(IBrandService brandService, UserClient userClient, RestTemplate restTemplate) {
        this.brandService = brandService;
        this.userClient = userClient;
        this.restTemplate = restTemplate;
    }

    // 1. 查询品牌列表
    @GetMapping("/list")
    @RequiresPermissions("manager:brand:list")
    public R list() {
        return R.ok(brandService.list());
    }

    // 2. 查询用户列表
    @GetMapping("/user/list")
    public R<List<User>> userList() {
        return userClient.list();
    }

    // 3. 查询用户端口
    @GetMapping("/user/getPort")
    public R getPort() {
        return userClient.getPort();
    }
    @GetMapping("/user/externalList")
    public R<List<User>> externalUserList() {
        return R.ok(Collections.emptyList());
    }
}
